import * as types from '../constants/articleTypes'
const initialState = {
	curTypeItem: {}, // 当前类型
	typeList: [], // 类型列表
	detailInfo: {}, // 文章详情
	list: [], // 当前类型的文章列表,
	errMsg: '',
	apiResult: '',
	canuseDomain: ''
}

export default function article(state = initialState, action) {
	switch (action.type) {
		case types.CATEGARY_FETCH_SUCCESS:
			return {
				...state,
				typeList: action.list,
				apiResult: 'success'
			}
			break
		case types.CATEGARY_FETCH_ERROR:
			return {
				...state,
				errMsg: action.err,
				apiResult: 'error'
			}
			break
		case types.DETAIL_FETCH_SUCCESS:
			return {
				...state,
				detailInfo: action.detail
			}
			break

		case types.SET_TYPE_ITEM:
			return {
				...state,
				curTypeItem: action.item
			}
			break
		case types.DOMAIN_IN_SUCCESS:
			return {
				...state,
				canuseDomain: action.item
			}
			break
		default:
			return state
	}
}
